/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author Eleftherios
 */
public class dataLayer {
    private final String ConnectionString = "jdbc:derby://localhost:1527/RadioStation_DB;create=true;user=admin1;password=admin1";

    public ResultSet ExecuteQuery(String SQL) {
        try
        {
            Connection con = DriverManager.getConnection(ConnectionString);
            Statement stmt = con.createStatement();
            return stmt.executeQuery(SQL);
        }
         catch ( SQLException err ) {
                System.out.println( err.getMessage( ) );
                return null;
                }
    }
    
    public long ExecuteUpdate(String SQL) {
         try
        {
            Connection con = DriverManager.getConnection(ConnectionString);
            Statement stmt = con.createStatement();
            return stmt.executeUpdate(SQL);
        }
         catch ( SQLException err ) {
                System.out.println( err.getMessage( ) );
                return 0;
                }
    }
  
}
